﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  MockMessageSender.cs
//    
// Abstract:
//
// This represents a dummy message sender implementation for testing CompositeMessageSender
// or any other components where we don't need to simulate the actual sending of the notification.
//
//--

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnhancedReminders.Dispatcher.UnitTests;

namespace Microsoft.EnhancedReminders.Dispatcher.UnitTests
{
    /// <summary>
    /// This represents a dummy message sender implementation for testing CompositeMessageSender
    /// or any other components where we don't need to simulate the actual sending of the notification.
    /// </summary>
    [StopPoint(true)]
    public class MockMessageSender : IMessageSender
    {
        private NotificationResult _result;

        /// <summary>
        /// ctor.
        /// </summary>
        /// <param name="result">The desired result of this notification</param>
        public MockMessageSender(NotificationResult result)
        {
            _result = result;
        }

        #region IMessageSender Members
        /// <summary>
        /// Called when a notification has been delivered
        /// </summary>
        public event EventHandler<DeliveryCompletedEventArgs> DeliverMessageCompleted;

        /// <summary>
        /// Calls the DeliverMessageCompleted event handler with the result specified
        /// by the constructor.
        /// </summary>
        public void DeliverMessageAsync()
        {
            EventHandler<DeliveryCompletedEventArgs> callback = DeliverMessageCompleted;

            if (callback != null)
            {
                callback.BeginInvoke(callback, new DeliveryCompletedEventArgs(_result), null /* callback */, null /* @object */);
            }
        }

        #endregion
    }

    /// <summary>
    /// Represents a version of MockMessage sender that is not treated as a stop point.
    /// </summary>
    [StopPoint(false)]
    public class NotStopPointMockMessageSender : MockMessageSender
    {
        /// <summary>
        /// ctor.
        /// </summary>
        /// <param name="result">The desired result of this notification</param>
        public NotStopPointMockMessageSender(NotificationResult result)
            : base(result)
        {
        }
    }
}
